home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / cup_viewhistory.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  6KB  |  236 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    VIEW TEAM SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  5.   ----------------------------------------------------
  6.                    Copyright  Mark Naughton 1997
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       091297   First release.
  12.            151297   Tidied display.
  13.            210499   Added support for CloseCup. History file would not be
  14.                     found as it did not have the date appended to the
  15.                     filename.
  16.            250899   Added error msg to file check.
  17.            280899   Converted to use locale. Some error messages, before
  18.                     reading the locale, will still be in English.
  19.  
  20. **************************************************************************
  21.  
  22. Procedure
  23. ---------
  24.  
  25. 1. Check file exists. If it doesn't, format a new filename from the
  26.    original, and then check this file.
  27. 2. Open '.cfh' file and read in winners, storing them and if the name
  28.    appears more than once, increment the number of wins for that team.
  29. 3. Read '.cfh' file in and store 'needed' lines.
  30. 4. Write teams for winners out to temp file and sort.
  31. 5. Check array and set marker if third place is found.
  32. 6. Display message. Display winners, runnersup, third place and fourth.
  33. 7. Read temp file and display winners with total wins. Exit.
  34.  
  35. ************************************************************************** */
  36. PARSE ARG league_stuff
  37.  
  38. version      = 1
  39. input_file   = '.cfh'
  40. first        = '*WINNER='
  41. second       = '*RUNNERUP='
  42. third        = '*THIRD='
  43. fourth       = '*FOURTH='
  44. cupnm        = '** History for '
  45. separator    = '*'
  46. teams.       = '???'
  47. wins.        = '???'
  48. lines.       = '???'
  49. counter      = 0
  50.  
  51.  
  52. league_file = "Data/" || league_stuff
  53.  
  54. if open(datafile,"Data/Football.locale",'r') then do
  55.    line = readln(datafile)
  56.    locdir = strip(line)
  57.    close(datafile)
  58. end
  59. else do
  60.    say
  61.    say "ERROR :    (Cup_ViewHistory)"
  62.    say
  63.    say "Cannot read 'Data/Football.locale' for the locale settings."
  64.    exit
  65. end
  66.  
  67. locdir = locdir"User/Cup_ViewHistory.data"
  68.  
  69. if open(datafile,"ENV:FootballRXPath",'r') then do
  70.    line = readln(datafile)
  71.    rxdir = strip(line)
  72.    close(datafile)
  73. end
  74. else
  75.    rxdir = "SYS:Rexxc/"
  76.  
  77. if exists(locdir) > 0 then do
  78.   address command rxdir'rx 'locdir
  79.   VarCount = getclip('VarCount')
  80.   do i = 1 to VarCount
  81.     interpret getclip('var.'i)
  82.   end
  83. end
  84. else do
  85.    say
  86.    say "ERROR :    (Cup_ViewHistory)"
  87.    say
  88.    say "Cannot find '"locdir"' to read locale settings."
  89.    exit
  90. end
  91.  
  92. if exists(league_file || input_file) = 0  then do
  93.    parse var league_file nlf "_" .
  94.    if exists(nlf || input_file) = 0 then do
  95.       say
  96.       say cvh_error
  97.       say
  98.       say cvh_one"'"league_file || input_file"'."
  99.       exit
  100.    end
  101.    league_file = nlf
  102. end
  103.  
  104. if open(datafile,league_file || input_file,'r') then do
  105.    do while ~eof(datafile)
  106.       line = readln(datafile)
  107.       if pos(cupnm,line) > 0 then
  108.          cupname = delstr(line,1,15)
  109.       if pos(first,line) > 0 then do
  110.          name = delstr(line,1,8)
  111.          notin = 0
  112.          do i=1 to counter
  113.             if pos(name,teams.i) > 0 then do
  114.                wins.i = wins.i + 1
  115.                notin = 1
  116.             end
  117.          end
  118.          if notin = 0 then do
  119.             counter = counter + 1
  120.             teams.counter = name
  121.             wins.counter  = 1
  122.          end
  123.       end
  124.    end
  125.    close(datafile)
  126. end
  127. else do
  128.    say
  129.    say cvh_error
  130.    say
  131.    say cvh_two"'"league_file||input_file"'"cvh_three
  132.    exit
  133. end
  134.  
  135. linect = 0
  136. if open(datafile,league_file || input_file,'r') then do
  137.    do while ~eof(datafile)
  138.       line = readln(datafile)
  139.       if pos('**',line) = 0 & length(line) > 2 & line ~= '' then do
  140.          linect = linect + 1
  141.          lines.linect = line
  142.       end
  143.    end
  144.    close(datafile)
  145. end
  146. else do
  147.    say
  148.    say cvh_error
  149.    say
  150.    say cvh_two"'"league_file||input_file"'"cvh_three
  151.    exit
  152. end
  153.  
  154. if counter > 1 then do
  155.    if open(datafile,"RAM:Football.tempcup",'w') then do
  156.       do i=1 to counter
  157.          writeln(datafile,left(wins.i,4)"     "teams.i)
  158.       end
  159.       close(datafile)
  160.    end
  161.    else do
  162.       say
  163.       say cvh_error
  164.       say
  165.       say cvh_four
  166.       exit
  167.    end
  168.    address command 'Exec/Sort4Chars '
  169. end
  170.  
  171. thirdp = 0
  172. do i=1 to linect
  173.    if pos(third,lines.i) > 0 then do
  174.       thirdp = 1
  175.       leave
  176.    end
  177. end
  178.  
  179. say
  180. say center(cvh_txt1""cupname,78)
  181. say "-------------------------------------------------------------------------------"
  182. say
  183.  
  184. do i=1 to linect
  185.    name = delstr(lines.i,1,8)
  186.    say cvh_txt2""upper(name)
  187.    i = i + 1
  188.    name = delstr(lines.i,1,10)
  189.    say cvh_txt3""name
  190.    if thirdp = 1 then do
  191.       i = i + 1
  192.       name = delstr(lines.i,1,7)
  193.       say cvh_txt4""name
  194.       i = i + 1
  195.       name = delstr(lines.i,1,8)
  196.       say cvh_txt5""name
  197.       say
  198.    end
  199.    else
  200.       say
  201. end
  202. say
  203. say
  204. say cvh_txt6
  205. say "-------------------------------------------------------------------------------"
  206. say
  207. i = 0
  208. if counter = 1 then do
  209.    say left(wins.1,4)"     "upper(teams.1)
  210.    say
  211. end
  212. else do
  213.    if open(datafile,"RAM:Football.tempcup",'r') then do
  214.       do while ~eof(datafile)
  215.          line = readln(datafile)
  216.          if i = 0 then do
  217.             say upper(line)
  218.             i = 1
  219.          end
  220.          else
  221.             say line
  222.       end
  223.       close(datafile)
  224.    end
  225.    else do
  226.       say
  227.       say cvh_error
  228.       say
  229.       say cvh_txt7
  230.       exit
  231.    end
  232.    address command 'delete >NIL: RAM:Football.tempcup'
  233. end
  234. say "-------------------------------------------------------------------------------"
  235.  
  236. exit